import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/views/layout/App.vue";
import ArticleManage from "./articleManage";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "DashboardHome",
    meta: {
      title: "登陆"
    },
    component: resolve => require(["@/views/login/Login.vue"], resolve)
  },
  {
    path: "/home",
    component: Layout,
    name: "Dashboard",
    redirect: "/home",
    meta: {
      title: "首页"
    },
    children: [
      {
        path: "/home",
        name: "DashboardHome",
        meta: {
          title: "首页"
        },
        component: resolve => require(["@/views/home/Index.vue"], resolve)
      },
      {
        path: "/home/sysindex",
        name: "Sysindex",
        meta: {
          title: "系统首页"
        },
        component: resolve => require(["@/views/system/Sysindex.vue"], resolve)
      },
      {
        path: "/home/admin",
        name: "Admin",
        meta: {
          title: "账户设置"
        },
        component: resolve => require(["@/views/system/Admin.vue"], resolve)
      },
      {
        path: "/home/system",
        name: "System",
        meta: {
          title: "系统信息"
        },
        component: resolve => require(["@/views/system/System.vue"], resolve)
      },
      {
        path: "/home/loginlog",
        name: "LoginLog",
        meta: {
          title: "登陆日志"
        },
        component: resolve => require(["@/views/system/LoginLog.vue"], resolve)
      },
      {
        path: "/home/test",
        name: "Test",
        meta: {
          title: "测试"
        },
        component: resolve => require(["@/views/system/Test.vue"], resolve)
      },
      {
        path: "/home/orders",
        name: "Orders",
        meta: {
          title: "订单信息"
        },
        component: resolve => require(["@/views/orders/orders.vue"], resolve)
      },
      {
        path: "/home/delivery",
        name: "delivery",
        meta: {
          title: "批量发货"
        },
        component: resolve => require(["@/views/orders/delivery.vue"], resolve)
      },
      {
        path: "/home/orderCause",
        name: "orderCause",
        meta: {
          title: "退货原因设置"
        },
        component: resolve =>
          require(["@/views/orders/returnOrderCause.vue"], resolve)
      },
      {
        path: "/home/categoryReport",
        name: "Report",
        meta: {
          title: "商品统计"
        },
        component: resolve =>
          require(["@/views/statistics/CategoryReport.vue"], resolve)
      },
      {
        path: "/goods/addOneCategory",
        name: "addOneCategory",
        meta: {
          title: "添加商品"
        },
        component: resolve =>
          require(["@/views/goods/addOneCategory.vue"], resolve)
      },
      {
        path: "/goods/spu",
        name: "spu",
        meta: {
          title: "商品列表"
        },
        component: resolve => require(["@/views/goods/spu.vue"], resolve)
      },
      {
        path: "/goods/brand",
        name: "brand",
        meta: {
          title: "品牌管理"
        },
        component: resolve => require(["@/views/goods/brand.vue"], resolve)
      },
      {
        path: "/home/album",
        name: "album",
        meta: {
          title: "图片库"
        },
        component: resolve =>
          require(["@/views/goods/album.vue"], resolve)
      },
      {
        path: "/home/albumList",
        name: "albumList",
        meta: {
          title: "图片库"
        },
        component: resolve =>
          require(["@/views/goods/albumList.vue"], resolve)
      },
      {
        path: "/goods/category",
        name: "category",
        meta: {
          title: "商品分类"
        },
        component: resolve => require(["@/views/goods/category.vue"], resolve)
      },
      {
        path: "/goods/template",
        name: "template",
        meta: {
          title: "规格参数"
        },
        component: resolve => require(["@/views/goods/mytemplate.vue"], resolve)
      },
      {
        path: "/goods/auditSpu",
        name: "auditSpu",
        meta: {
          title: "商品审核"
        },
        component: resolve => require(["@/views/goods/auditSpu.vue"], resolve)
      },
      {
        path: "/goods/spuComment",
        name: "spuComment",
        meta: {
          title: "商品评价"
        },
        component: resolve => require(["@/views/goods/spuComment.vue"], resolve)
      },
      {
        path: "/home/flowStatis",
        name: "flowStatis",
        meta: {
          title: "流量统计"
        },
        component: resolve =>
          require(["@/views/statistics/FlowStatistcs.vue"], resolve)
      },
      {
        path: "/home/orderStatis",
        name: "orderStatis",
        meta: {
          title: "交易统计"
        },
        component: resolve =>
          require(["@/views/statistics/OrderStatistcs.vue"], resolve)
      },
      {
        path: "/home/memberStatistcs",
        name: "memberStatistcs",
        meta: {
          title: "会员统计"
        },
        component: resolve =>
          require(["@/views/statistics/MemberStatistcs.vue"], resolve)
      },
      {
        path: "/home/searchStatistcs",
        name: "searchStatistcs",
        meta: {
          title: "搜索统计"
        },
        component: resolve =>
          require(["@/views/statistics/SearchStatistcs.vue"], resolve)
      },
      {
        path: "/home/ad",
        name: "ad",
        meta: {
          title: "广告"
        },
        component: resolve =>
          require(["@/views/advertisement/AD.vue"], resolve)
      },
      {
        path: "/home/returnGoods",
        name: "returnGoods",
        meta: {
          title: "退货申请处理"
        },
        component: resolve =>
          require(["@/views/orders/returnGoods.vue"], resolve)
      },
      {
        path: "/home/order/orderDetails",
        name: "orderDetails",
        meta: {
          title: "订单详情"
        },
        component: resolve =>
          require(["@/views/orders/orderDetails.vue"], resolve)
      },
      {
        path: "/goods/recycleSpu",
        name: "recycleSpu",
        meta: {
          title: "商品回收站"
        },
        component: resolve =>
          require(["@/views/goods/RecycleSpu.vue"], resolve)
      },
      {
        path: "/goods/para",
        name: "para",
        meta: {
          title: "参数列表"
        },
        component: resolve =>
          require(["@/views/goods/para.vue"], resolve)
      },
      {
        path: "/goods/spec",
        name: "spec",
        meta: {
          title: "规格列表"
        },
        component: resolve =>
          require(["@/views/goods/Spec.vue"], resolve)
      }, {
        path: "/home/order/orderDetails/updateGoods",
        name: "updateGoods",
        meta: {
          title: "修改商品信息"
        },
        component: resolve =>
          require(["@/views/orders/updateGoods.vue"], resolve)
      },
      {
        path: "/home/orderSettings",
        name: "orderSettings",
        meta: {
          title: "订单设置"
        },
        component: resolve =>
          require(["@/views/orders/orderSettings.vue"], resolve)
      },
      {
        path: "/home/cancelOrder",
        name: "cancelOrder",
        meta: {
          title: "取消订单"
        },
        component: resolve =>
          require(["@/views/orders/cancelOrder.vue"], resolve)
      },
      {
        path: "/home/returnManey",
        name: "returnManey",
        meta: {
          title: "退款申请"
        },
        component: resolve =>
          require(["@/views/orders/returnManey.vue"], resolve)
      },
      {
        path: "/home/returnManeyItem",
        name: "returnManeyItem",
        meta: {
          title: "退款申请详细"
        },
        component: resolve =>
          require(["@/views/orders/returnManeyItem.vue"], resolve)
      },
      {
        path: "/home/returnGoods/returnGoodsItem",
        name: "returnGoodsItem",
        meta: {
          title: "退货申请详细"
        },
        component: resolve =>
          require(["@/views/orders/returnGoodsItem.vue"], resolve)
      },
      {
        path: "/home/user",
        name: "user",
        meta: {
          title: "用户查询"
        },
        component: resolve =>
          require(["@/views/user/User.vue"], resolve)
      },
      {
        path: "/home/userByIndex",
        name: "userByIndex",
        meta: {
          title: "用户详情"
        },
        component: resolve =>
          require(["@/views/user/UserByinfo.vue"], resolve)
      }
    ]
  },
  ArticleManage,
  {
    path: "/login",
    name: "Login",
    meta: {
      title: "后台登录",
      keepAlive: false
    },
    components: {
      blank: resolve => require(["@/views/login/Login.vue"], resolve)
    }
  }
];

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err);
};

const router = new VueRouter({
  routes
});

export default router;
